<!--
 * @Author: [kangjie]
 * @Date: 2022-03-31 10:21:28
 * @LastEditors: [kangjie]
 * @LastEditTime: 2022-03-31 14:18:11
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>局部注册</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
  <div id="app">
    <my-com-a></my-com-a>
    <!-- <my-com-b></my-com-b> -->
  </div>
  <script>
    // 创建一个B组件
    let mycomB = {
      template: `
          <div>
            B组件
          </div>
        `
    };
    // 创建组件
    let mycomA = {
      // 局部注册
      components: {
        'my-com-b': mycomB
      },
      data() {
        return {

        }
      },
      template: `
          <div>
            A组件
            <my-com-b></my-com-b>
          </div>
        `
    };



    new Vue({
      // 局部注册组件
      components: {
        'my-com-a': mycomA
      },
      el: "#app",
      data: {
        msg: '我是父组件'
      },
      methods: {

      }
    })
  </script>
</body>

</html>